package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LhkHotelDetails;
import com.ruoyi.system.service.ILhkHotelDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实体详情Controller
 * 
 * @author ruoyi
 * @date 2025-06-06
 */
@RestController
@RequestMapping("/system/f_details")
public class LhkHotelDetailsController extends BaseController
{
    @Autowired
    private ILhkHotelDetailsService lhkHotelDetailsService;

    /**
     * 查询实体详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:f_details:list')")
    @GetMapping("/list")
    public TableDataInfo list(LhkHotelDetails lhkHotelDetails)
    {
        startPage();
        List<LhkHotelDetails> list = lhkHotelDetailsService.selectLhkHotelDetailsList(lhkHotelDetails);
        return getDataTable(list);
    }

    /**
     * 导出实体详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:f_details:export')")
    @Log(title = "实体详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LhkHotelDetails lhkHotelDetails)
    {
        List<LhkHotelDetails> list = lhkHotelDetailsService.selectLhkHotelDetailsList(lhkHotelDetails);
        ExcelUtil<LhkHotelDetails> util = new ExcelUtil<LhkHotelDetails>(LhkHotelDetails.class);
        util.exportExcel(response, list, "实体详情数据");
    }

    /**
     * 获取实体详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:f_details:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return success(lhkHotelDetailsService.selectLhkHotelDetailsByDetailId(detailId));
    }

    /**
     * 新增实体详情
     */
    @PreAuthorize("@ss.hasPermi('system:f_details:add')")
    @Log(title = "实体详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LhkHotelDetails lhkHotelDetails)
    {
        return toAjax(lhkHotelDetailsService.insertLhkHotelDetails(lhkHotelDetails));
    }

    /**
     * 修改实体详情
     */
    @PreAuthorize("@ss.hasPermi('system:f_details:edit')")
    @Log(title = "实体详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LhkHotelDetails lhkHotelDetails)
    {
        System.out.println("lhkHotelDetails = " + lhkHotelDetails);
        return toAjax(lhkHotelDetailsService.updateLhkHotelDetails(lhkHotelDetails));
    }

    /**
     * 删除实体详情
     */
    @PreAuthorize("@ss.hasPermi('system:f_details:remove')")
    @Log(title = "实体详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds)
    {
        return toAjax(lhkHotelDetailsService.deleteLhkHotelDetailsByDetailIds(detailIds));
    }
}
